package cn.lyn4ever.cataccount.controller;

import cn.lyn4ever.cataccount.entity.Property;
import cn.lyn4ever.cataccount.entity.User;
import cn.lyn4ever.cataccount.service.PropertyService;
import cn.lyn4ever.cataccount.service.UserService;
import cn.lyn4ever.common.R;
import cn.lyn4ever.common.SecurityParameter;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * (Property)表控制层
 *
 * @author makejava
 * @since 2019-09-21 16:21:51
 */
@RestController
@RequestMapping("property")
public class PropertyController {
    /**
     * 服务对象
     */
    @Resource
    private PropertyService propertyService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Property selectOne(Integer id) {
        return this.propertyService.queryById(id);
    }


    /**
     * 查询指定用户的财产
     * @return
     */
    @RequestMapping("list")
    @SecurityParameter
    public R listAll(@RequestBody Property property){
        return propertyService.listAll(property);
    }

    /**
     * 查询财产统计
     * @param property
     * @return
     */
    @RequestMapping("total")
    @SecurityParameter
    public R getAnalysisProperty(@RequestBody Property property){
        return propertyService.getAnalysisProperty(property);
    }

    /**
     * 添加新的财产
     * @param property
     * @return
     */
    @RequestMapping("insertOne")
    @SecurityParameter
    public R insertOne(@RequestBody Property property){
        return propertyService.insert(property);
    }

}